<?php

namespace $namspace;
use app\$app\controller\Base;
use think\facade\Request;
use think\facade\View;

class $controller extends Base
{
    protected $model;
    public function initialize()
    {
        parent::initialize();
        $this->model = new $modelPath;
    }
    public function index(){
        if (Request::isPost()) {
            $keys = $this->request->post('keys', '', 'trim');
            $option = [
                /*'where' => [
                    ['name','like',"%".$keys."%"]
                ],
                'with' => ['model'], 关联的模型名称
                'visible' => [
                    'model' => ['****']  // 关联的模型名称要显示的字段名，默认展示全部
                ]*/
            ];
            $list = $this->model->loadList($option);
            if ($list['result'] == 'success'){
                $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['list'], 'count' => $list['page']['total']];
            }else{
                $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => [], 'count' => 0];
            }
            return $result;
        }
        return view();
    }

}